package org.example.springbootserver.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import lombok.RequiredArgsConstructor;
import org.example.springbootserver.dao.EmojiDao;
import org.example.springbootserver.pojo.Emoji;
import org.example.springbootserver.pojo.R;
import org.example.springbootserver.service.EmojiService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
@RequiredArgsConstructor
public class EmojiServiceImpl implements EmojiService {
    @Autowired
    private EmojiDao emojiDao;

    @Override
    public R getEmojiByPage(int pageSize, int current) {
        Page<Emoji> page=new Page<>(current,pageSize);
        page=emojiDao.selectPage(page,new QueryWrapper<>());
        List<Emoji> records=page.getRecords();
        if (records.isEmpty())
            return R.error("无记录");
        return R.success(records);
    }
}
